<template>
  <view class="commonBox" @click="goDetails">
    <view class="header">
      <view :style="{ width: info.status !== '2' ? '83%' : '100%' }">
        <view class="left">
          <image class="img" :src="info.avatar" mode="scaleToFill" />
          <view class="nameBox">
            <view class="name_line">
              <view class="name">{{ info.name }}</view>
              <view class="authLabel" v-if="info.authFlag === '1'"><image src="../static/home/yrz.png" mode="scaleToFill" />已认证</view>
              <view class="gs" :style="{ maxWidth: (info.promotionFlag === '1' && !ismy) || info.status !== '2' ? '230rpx' : '300rpx' }">{{ info.company }}</view>
            </view>
            <view class="name_date">{{ info.createTime }}</view>
          </view>
        </view>
      </view>

      <view class="status" v-if="info.status !== '2'" :style="{ color: statusObj[info.status].color }">{{ statusObj[info.status].text }}</view>
      <view v-if="info.promotionFlag === '1' && !ismy" class="right">广告</view>
    </view>
    <view class="ctn"> {{ info.content }} </view>
    <u-scroll-list :indicator="false">
      <view v-for="(item, index) in info.fileList" :key="index">
        <image class="pjImg" :src="item" mode=""></image>
      </view>
    </u-scroll-list>
    <view class="funList">
      <view class="funItem">
        <u-icon name="chat" color="#666669" size="24"></u-icon>
        {{ info.commentCount }}
      </view>
      <view class="funItem">
        <u-icon name="heart" color="#666669" size="24"></u-icon>
        {{ info.likeCount }}
      </view>
      <view class="funItem" @click.stop="goPage(`/pages/myPage/MyBusinessCard/MyBusinessCard?cardId=${info?.userId}&pageType=other`)">
        <image src="../static/home/lx.png" mode="scaleToFill" />
        联系TA
      </view>
    </view>
    <slot name="topping"></slot>
  </view>
</template>

<script lang="ts" setup>
import dayjs from "dayjs";
import { goPage } from "../utils/commonFn";
import { ref } from "vue";
const { info } = defineProps<{
  info: myTypes.myPostList;
  ismy?: boolean;
}>();
const statusObj: any = {
  "1": {
    text: "申请中",
    color: "#1676fd",
  },
  "2": {
    text: "",
    color: "",
  },
  "3": {
    text: "拒绝",
    color: "#cc463d",
  },
};
const goDetails = () => {
  console.log(info);
  if (info.status !== "2") {
    uni.showToast({
      title: "当前帖子还未审核通过",
      icon: "none",
    });
    return;
  }
  goPage(`/pages/findOrder/orderDetails?id=${info.id}`);
};
</script>

<style scoped lang="less">
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .left {
    display: flex;
    align-items: center;
    overflow: hidden;
    flex-wrap: nowrap;
    .img {
      width: 88rpx;
      height: 88rpx;
      margin-right: 16rpx;
      border-radius: 50rpx;
    }
    .nameBox {
      .name_line {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding: 8rpx 0;
        .hg {
          width: 28rpx;
          height: 28rpx;
          margin: 0 3rpx;
        }
        .name {
          font-size: 30rpx;
          font-family: PingFangSC, PingFang SC;
          font-weight: 500;
          color: #1e1e1e;
          line-height: 42rpx;
          max-width: 150rpx;
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
        }
        .gs {
          font-size: 24rpx;
          font-family: PingFangSC, PingFang SC;
          font-weight: 500;
          color: #1676fd;
          margin-left: 8rpx;
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
        }
      }
      .name_date {
        font-size: 22rpx;
        color: #bebebe;
        line-height: 32rpx;
        margin-top: 8rpx;
      }
    }
  }
  .right {
    background: #f5f7f9;
    border-radius: 20rpx;
    width: 80rpx;
    line-height: 45rpx;
    text-align: center;
    font-size: 22rpx;
    font-family: PingFangSC, PingFang SC;
    font-weight: 500;
    color: #bebebe;
  }
}
.ctn {
  font-size: 28rpx;
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  color: #1e1e1e;
  line-height: 46rpx;
  margin-top: 32rpx;
  margin-bottom: 16rpx;
}
.pjImg {
  width: 208rpx;
  height: 208rpx;
  border-radius: 16rpx;
  margin-right: 6rpx;
}
.funList {
  width: 85%;

  padding: 3rp x 50rpx;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto;
  .funItem {
    display: flex;
    align-items: center;
    font-size: 24rpx;
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    color: #666669;
    line-height: 46rpx;
    image {
      width: 32rpx;
      height: 32rpx;
      margin-right: 12rpx;
    }
  }
}
.status {
  max-width: 97rpx;
  font-size: 32rpx;
}
</style>
